/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pruebawallayllu;

import BESA.ExceptionBESA;
import BESA.Kernell.Agent.Event.EventBESA;
import BESA.Kernell.Agent.KernellAgentExceptionBESA;
import BESA.Kernell.System.AdmBESA;
import BESA.Kernell.System.Directory.AgHandlerBESA;
import agents.factory.ChatFactoryAgent;
import agents.factory.ChatFactoryAgentState;
import agents.factory.EndChatGuard;
import co.edu.javeriana.ayllu.agents.factoryagent.FA_CMACreationGuard;
import co.edu.javeriana.ayllu.agents.factoryagent.FactoryAgent;
import co.edu.javeriana.ayllu.data.Ayllu_Agent_Creation_Message;
import co.edu.javeriana.ayllu.directories.user.UserDirectory;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Ayllu
 */
public class PruebaWallAyllu {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {      

        try {
             AdmBESA.getInstance();
        } catch (Exception e) {
            Logger.getLogger(PruebaWallAyllu.class.getName()).log(Level.SEVERE,"ERROR INICIALIZANDO EL ADMINISTRADOR: ",e);
            System.exit(1);
        }
        //CREANDO DIRECOTORIO DE USUARIOS
        CreadorUsuariosWall.crearEjemplo();
        //OBTENIENDO DIRECTORIO DE USUARIOS APRENDIZ
        UserDirectory ud = UserDirectory.getInstance();
        List<AgHandlerBESA> smaList = ud.getUsersbyHability("Aprendiz");
        //CREANDO SERVICIO DE CHAT
        ChatFactoryAgentState factorySTate = new ChatFactoryAgentState();
        try {
            AdmBESA adm = AdmBESA.getInstance();
            FactoryAgent.prepareInstance();
            ChatFactoryAgent factAgent = new ChatFactoryAgent("Factory", factorySTate, 0.91);
            factAgent.start();
            Ayllu_Agent_Creation_Message cmaCreationMessage = new Ayllu_Agent_Creation_Message("CMA_CHAT",factAgent.getAid(),EndChatGuard.class);
            cmaCreationMessage.setMessage(smaList);
            AgHandlerBESA factAgenHand = adm.getHandlerByAid(factAgent.getAid());
            EventBESA creationEvent = new EventBESA(FA_CMACreationGuard.class.getName(),cmaCreationMessage);
            factAgenHand.sendEvent(creationEvent);
        } catch (KernellAgentExceptionBESA ex) {
            Logger.getLogger(PruebaWallAyllu.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ExceptionBESA ex) {
            Logger.getLogger(PruebaWallAyllu.class.getName()).log(Level.SEVERE, null, ex);
        }
        
    }
}
